<?php
namespace Seller\Model;
class GoodsDistributionModel extends CommonModel{
    
    protected $tableName = 'goods_distribution';
    
   


    
    //产品列表
    public function getList($where = array(), $order = array('d.id'=>"DESC")) {
        //开始分页信息
        $p = isset($_GET['p']) ? intval($_GET['p']) : '1';
        $count = $this->alias('d')->where($where)->count();
        //分页
        $pagesize = 20; #每页数量
        $offset = $pagesize * ($p - 1); //计算记录偏移量
        $page = new \Think\Page($count, $pagesize);
        $page = $page->show();
        $limit = $offset . ',' . $pagesize;
        $list = $this
                ->join('as d LEFT JOIN zt_customer as c ON c.id = d.customer_id')
                ->join('LEFT JOIN zt_goods as g ON g.id = d.goods_id')
                ->join('LEFT JOIN zt_customer as cu ON cu.id = d.supply_customer_id')
                ->where($where)->order($order)->limit($limit)
                ->field('d.*,c.shop_name as distribution_name,cu.shop_name as supply_name,g.name')
                ->select();
   
        $arr = array('count' => $count, 'list' => $list, 'page' => $page,);
        return $arr;
    }
}